home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / IATHREAD.PAK / README.TXT < prev    next >
Text File  |  1997-05-06  |  3KB  |  62 lines

  1. IAThread - Based on THREADS/BLANDMDI
  2.  
  3. THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  4. ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  5. THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  6. PARTICULAR PURPOSE.
  7.  
  8. Copyright (C) 1993-1995  Microsoft Corporation.  All Rights Reserved.
  9.  
  10.  
  11. PURPOSE:
  12.     Shows how to create a multithreaded MDI application, and allows the user
  13.     to adjust relative thread priorities to experiment with the feel of a
  14.     multithreaded application.
  15.  
  16. USES:
  17.     As a starting point for writing multithreaded MDI applications, and as
  18.     a learning tool for setting relative thread priorities within an
  19.     application.
  20.  
  21. COMMENTS:
  22.     This application has one main thread that handles all of the user
  23.     interface.  All child window procedures run in the main user interface
  24.     thread.  When a child window is created, a new thread is created that
  25.     does work on the "document" that the child window represents, and draws
  26.     in the child's client area.  Each child window uses its window extra
  27.     bytes to store a pointer to a data structure that is shared between the
  28.     child window procedure and the child's worker thread.  One important
  29.     part of this data structure is a critcal section that is used to
  30.     synchronize access to the rest of the data structure between the user
  31.     interface thread running the child window procedure, and the child's
  32.     worker thread.
  33.  
  34.     There is one general usability feature that is not obvious.  When a user
  35.     selects the Time Critical or Highest thread priorities, all other
  36.     threads in the application slow down immensely.  When a time critical
  37.     thread is running, all other threads in the application stop executing.
  38.     To prevent time critical and highest priority threads from rendering
  39.     IAThread useless, these threads have a timeout mechanism that will
  40.     reset their priorities after a while.  The function that implements
  41.     the timeout check is ReducePriority() in MISC.C.  ReducePriority will also
  42.     reduce the process's priority class for the same reason.
  43.  
  44.     When a time critical thread starts, it usually preempts the user-
  45.     interface thread before the Set Priority/Class dialog box goes away.
  46.     Thus, the dialog stays on the screen although it doesn't do any more
  47.     processing.  Applications that want to dynamically adjust priorities
  48.     and make sure that dialogs go away need to prevent threads with higher
  49.     priorities than the thread handling the dialog from running.
  50.  
  51. MODULE MAP:
  52.     Dispatch - Message dispatching routines
  53.     WinMain  - Calls initialization functions and processes the message loop
  54.     Iathread - Contains the window procedure for the main application window
  55.     Init     - Performs application and instance specific initialization
  56.     About    - Defines a standard about dialog box.
  57.     Misc     - Defines the application specific commands not related to
  58.                  a specific module.
  59.     MDIChild - Creates the MDI client window and the MDI Children.  Also it
  60.                  contains the window procedure for the MDI children
  61.     Priority - Contains all functions related to the Priority dialog box.
  62.